package top.cflwork.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

import top.cflwork.dao.BuyDao;
import top.cflwork.vo.BuyVo;
import top.cflwork.service.BuyService;
import top.cflwork.common.SequenceId;


@Service
public class BuyServiceImpl implements BuyService {
	@Autowired
	private BuyDao buyDao;
    @Autowired
    private SequenceId sequenceId;
	@Override
    @Transactional
	public BuyVo get(String id){
		return buyDao.get(id);
	}
	
	@Override
    @Transactional
	public List<BuyVo> list(BuyVo buyVo){
		return buyDao.list(buyVo);
	}
	
	@Override
    @Transactional
	public long count(BuyVo buyVo){
		return buyDao.count(buyVo);
	}
	
	@Override
    @Transactional
	public int save(BuyVo buy){
	    buy.setId(sequenceId.nextId());
	    return buyDao.save(buy);
	}
	
	@Override
    @Transactional
	public int update(BuyVo buy){
		return buyDao.update(buy);
	}
	
	@Override
    @Transactional
	public int remove(String id){
		return buyDao.remove(id);
	}
	
	@Override
    @Transactional
	public int batchRemove(String[] ids){
		return buyDao.batchRemove(ids);
	}

    @Override
    @Transactional
    public int batchSave(List<BuyVo> buyList){
			buyList.forEach(e -> e.setId(sequenceId.nextId()));
        return buyDao.batchSave(buyList);
    }
}
